// -----------------------------------------------------------------------
//  <copyright file="RoleResourceOutDto.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2025 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025/1/4 19:05</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Filters;


namespace DaprPlus.Authorization.Application.Queries;

public class RoleResourceOutDto
{
    /// <summary>
    /// 获取或设置 主键，唯一标识
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 获取或设置 角色编号
    /// </summary>
    public long RoleId { get; set; }

    /// <summary>
    /// 获取或设置 资源编号
    /// </summary>
    public long ResourceId { get; set; }

    /// <summary>
    /// 获取或设置 资源名称
    /// </summary>
    public required string ResourceName { get; set; }

    /// <summary>
    /// 获取或设置 资源代码
    /// </summary>
    public required string ResourceCode { get; set; }

    /// <summary>
    /// 获取或设置 资源元数据
    /// </summary>
    public string? MetadataJson { get; set; }

    public string? AllowedOperationsJson { get; set; }

    /// <summary>
    /// 获取或设置 资源操作集合
    /// </summary>
    public string[] Operations { get; set; } = [];

    public ResourceOperation[] AllowedOperations =>
        string.IsNullOrEmpty(AllowedOperationsJson)
            ? []
            : AllowedOperationsJson.FromTextJson<ResourceOperation[]>()!;

    /// <summary>
    /// 获取或设置 各操作的过滤条件组
    /// </summary>
    public Dictionary<string, Dictionary<DataOperation, FilterGroup>> FilterGroups { get; set; } = [];

    public EntityMetadata? EntityMetadata => string.IsNullOrEmpty(MetadataJson)
        ? null
        : MetadataJson.FromTextJson<EntityMetadata>()!;

    /// <summary>
    /// 获取或设置 创建时间
    /// </summary>
    public DateTime CreatedTime { get; set; }

    /// <summary>
    /// 获取或设置 是否锁定
    /// </summary>
    public bool IsLocked { get; set; }
}
